using System;
using System.IO;
using System.Collections.Generic;
using PPIDesktopClient.Logic;
using PPIDesktopClient.General;
using PPIDesktopClient.General;
using System.Text;

namespace PPIDesktopClient.Entities
{
	[Serializable]
	public class EVendor_Visit_XMissionStructures_Image : EBaseImage 
	{
		#region Fields
        Int32 m_ImageServerID;
        Int32 m_PoleServerID;
        Int32 m_StructureServerID;
        DateTime m_UploadedDate;
        
		#endregion Miembros Privados

		#region Properties
        public Int32 ImageServerId
        {
            get { return m_ImageServerID; }
            set { m_ImageServerID = value; }
        }
        public Int32 PoleServerId
        {
            get{return m_PoleServerID;}
            set { m_PoleServerID = value; }
        }
        public Int32 StructureServerID
        {
            get { return m_StructureServerID; }
            set { m_StructureServerID = value; }
        }
        public DateTime UploadDate
        {
            get { return m_UploadedDate; }
            set { m_UploadedDate = value; }
        }
       

		#endregion Propiedades

		#region Constructors
		#region summary
		/// <summary>
		/// Date: 04/28/2008
		/// Time: 14:26:44
		/// Generated by: VMCoder
		/// Generated using VirtualGenerator
		/// </summary>
		#endregion summary
		public EVendor_Visit_XMissionStructures_Image()
		:base()
        {
            IsDeleted = false;
            IsDesasocciated = true;
            if(m_key == "PRODUCTIVE_PPI")
            {
                m_ImageWebserviceFolder = Constants.K_DEVVENDORFTPFOLDER;
                m_ImageWebFolder = Constants.K_DEVVENDORWEBFOLDER;
            }
            else
            {
                m_ImageWebserviceFolder = Constants.K_BETAVENDORFTPFOLDER;
                m_ImageWebFolder = Constants.K_BETAVENDORWEBFOLDER;
            }

            m_ImageLocalFolder = Constants.K_ImageCachePath;

		}

		#region summary
		/// <summary>
		/// Date: 04/28/2008
		/// Time: 14:26:44
		/// Generated by: VMCoder
		/// Generated using VirtualGenerator
		/// </summary>
		#endregion summary
		public EVendor_Visit_XMissionStructures_Image(Int32 vendor_Visit_XMissionStructures_ImageId)
			: this()
		{
			Id = vendor_Visit_XMissionStructures_ImageId;

		}

		#region summary
		/// <summary>
		/// Date: 04/28/2008
		/// Time: 14:26:44
		/// Generated by: VMCoder
		/// Generated using VirtualGenerator
		/// </summary>
		#endregion summary
		public EVendor_Visit_XMissionStructures_Image(Int32 vendor_Visit_XMissionStructures_ImageId, EVendor_Visit_XMissionStructure vendor_Visit_XMissionStructure, double direction, double latitude, double longitude, double altitude, Int32 satelliteCount, DateTime satelliteTime, bool solutionAvailable, string filename, EVendor_Visit_XMissionStructures_Pole vendor_Visit_XMissionStructures_Pole)
			: this(vendor_Visit_XMissionStructures_ImageId)
		{
			Asset = vendor_Visit_XMissionStructure;
			Direction = direction;
			Latitude = latitude;
			Longitude = longitude;
			Altitude = altitude;
			SatelliteCount = satelliteCount;
			SatelliteTime = satelliteTime;
			SolutionAvailable = solutionAvailable;
			FileName = filename;
			Pole = vendor_Visit_XMissionStructures_Pole;

		}

		#endregion Constructores


        #region Override
        
        public override List<EBaseImage> GetServer(int offset)
        {
            List<EVendor_Visit_XMissionStructures_Image> _Images = LVendor_Visit_XMissionStructures_Image.GetServerImages(offset);
            List<EBaseImage> _BaseImages = new List<EBaseImage>();
            foreach (EVendor_Visit_XMissionStructures_Image  i in _Images)
            {
                _BaseImages.Add(i);
            }
            return _BaseImages;
        }

        public override EBaseAsset GetAsset()
        {
            return Asset;
        }

        public override string GetHtml()
        {
            string sHtmlTemp ="";
            if (!((EVendor_Visit_XMissionStructure)Asset).IsMobile)
            {
                ConfigReader r = ConfigReader.GetInstance();
                string mode = r.GetConnectionType();
                string dirName = GetLocalPath().Directory.Name;
                string fileName = Asset.Id + "_" + Id;



                //sHtmlTemp = "               <td><a href=\"http://www.dev-poleposition.com/Dev/WebSite/ImagePreview.aspx?Mode=" + mode + "&Type=1&w=0&h=0&IdImage=" + Id + "\"><img src=\"" + File.FullName + "\" border=\"0\"/></a></td>";
                //sHtmlTemp = "               <td><a href=\"http://www.dev-poleposition.com/Dev/WebSite/ImagePreview.aspx?mode=" + mode + "&Type=1&w=0&h=0&fn=" + fileName + "&dn=" + dirName + "\"><img src=\"http://www.dev-poleposition.com/Dev/WebSite/ImagePreview.aspx?mode=" + mode + "&Type=1&w=" + Constants.k_PREVIEWIMAGEHEIGHT + "&h=" + Constants.k_PREVIEWIMAGEHEIGHT + "&fn=" + fileName + "&dn=" + dirName + "\" border=\"0\"/></a></td>";
                sHtmlTemp = "               <td><a href=\"#" + GetPlacemarkId() + ";balloon\"><img src=\"http://www.dev-poleposition.com/Dev/WebSite/ImagePreview.aspx?mode=" + mode + "&Type=1&w=" + Constants.k_PREVIEWIMAGEHEIGHT + "&h=" + Constants.k_PREVIEWIMAGEHEIGHT + "&fn=" + fileName + "&dn=" + dirName + "\" border=\"0\"/></a></td>";
            }
            else
            {
                sHtmlTemp = "               <td><img src=\"" + File.FullName + "\" border=\"0\"/></td>";
            }
            return sHtmlTemp;

        }

        protected override string GetPlacemarkId()
        {
            return "VendorImage_" + Id.ToString();
        }

        public override string GetHtmlDescription()
        {
            ConfigReader r = ConfigReader.GetInstance();
            string mode = r.GetConnectionType();
            string dirName = GetLocalPath().Directory.Name;
            string fileName = Asset.Id + "_" + Id;

            StringBuilder _Shtml = new StringBuilder();
            _Shtml.AppendLine("<table style='font-family:Verdana; font-size:10px;' border='0'>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td><a href=\"http://www.dev-poleposition.com/Dev/WebSite/ImagePreview.aspx?mode=" + mode + "&Type=1&w=0&h=0&fn=" + fileName + "&dn=" + dirName + "\" ><img src=\"http://www.dev-poleposition.com/Dev/WebSite/ImagePreview.aspx?mode=" + mode + "&Type=1&w=0&h=0&fn=" + fileName + "&dn=" + dirName + "\" ></a></td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine("</table>");
            return _Shtml.ToString();
        }

        #endregion

        #region public Methods

        public void Delete()
        {
            IsDeleted = true;
        }

       
        #endregion

    }
}

